#pragma once
#include "GameEngine.h"
#include <cmath>
#include <time.h>
#include "DebugState.h"




class MenuState : public GameState
{
public:

	void Init(GameEngine* game)
	{
		printf("=======Menustate\n");


		ColorButton = sf::Color::Red;
	}



	void Cleanup()
	{


		printf("=======Menustate End\n");
	}

	void Pause()
	{

	}
	void Resume()
	{

	}

	void HandleEvents(GameEngine* game)
	{
		sf::Event event;
		game->_Window.PollEvent(event);
		if (event.Type == sf::Event::Closed)
		{
			//game->Quit();
		}
		if ((event.Type == sf::Event::KeyPressed) && event.KeyPressed == sf::Keyboard::Escape)
		{
			game->Quit();
		}
		if (event.Type == sf::Event::Resized)
		{
			game->_Width = event.Size.Width;
			game->_Height = event.Size.Height;
			game->_Window.SetView(sf::View(sf::FloatRect(0,0,(float)event.Size.Width,(float)event.Size.Height)));
		}
		if (sf::Mouse::IsButtonPressed(sf::Mouse::Left))
		{
			if (RectButton.Contains(sf::Mouse::GetPosition(game->_Window)))
			{
				ColorButton = sf::Color::Blue;
				game->ChangeState(DebugState::Instance());
			}
		}
		game->_Time.Reset();
	}




	void Update(GameEngine* game)
	{
		RectButton = sf::Rect<int>(game->_Width/2-(game->_Width/8),
			game->_Height/2-game->_Height/8,
			game->_Width/4,
			game->_Height/4);

		Button = sf::Shape::Rectangle((float)RectButton.Left,(float)RectButton.Top,(float)RectButton.Width,(float)RectButton.Height,ColorButton);

	}

	void Draw(GameEngine* game)
	{
		game->_Window.Clear(sf::Color(28,28,28));

		game->_Window.Draw(Button);

		game->_Window.Display();
	}

	static MenuState* Instance()
	{
		return &iMenustate;
	}
protected:
	MenuState(){};
private:

	static MenuState iMenustate;

	sf::Shape Button;
	sf::Rect<int> RectButton;
	sf::Color ColorButton;
};

MenuState MenuState::iMenustate;